package com.example.picturetest;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import cn.bingoogolapple.qrcode.zxing.ZXingView;


public class CodeActivity extends AppCompatActivity implements View.OnClickListener{

    private Button scanButton;
    private ZXingView mZXingView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_code);
//        ZXingLibrary.initDisplayOpinion(this);
        scanButton = findViewById(R.id.sButton);
        scanButton.setOnClickListener(this);


    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        Log.i("tag", "回调");
//        if (requestCode == 123) {
            //处理扫描结果（在界面上显示）
            if (null != data) {
                if (data != null) {

                    String content = data.getStringExtra("codedContent");

                   Log.i("codetest","扫描结果为：" + content);
                }
//                Bundle bundle = data.getExtras();
//                if (bundle == null) {
//                    return;
//                }
//                if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_SUCCESS) {
//                    String result = bundle.getString(CodeUtils.RESULT_STRING);
//                    Toast.makeText(this, "解析结果:" + result, Toast.LENGTH_LONG).show();
//                } else if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_FAILED) {
//                    Toast.makeText(CodeActivity.this, "解析二维码失败", Toast.LENGTH_LONG).show();
//                }
            }
//        }
    }

    @Override
    public void onClick(View v) {
//        Intent intent = new Intent(CodeActivity.this, CaptureActivity.class);
//        startActivityForResult(intent, 123);
    }
}
